<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>仓库管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../resources/lib/layui-v2.5.5/css/layui.css" media="all" />
    <link rel="stylesheet" href="../../../../resources/css/public.css" media="all" />
</head>
<body >
<div class="layuimini-container">
<!--搜索条件开始-->
	 <div class="layuimini-main">
		<fieldset class="layui-elem-field layuimini-search">
			<legend>搜索信息</legend>
			<div style="margin: 10px 10px 10px 10px">
				<form class="layui-form layui-form-pane" lay-filter="searchFrm" id="searchFrm" name="searchFrm" method="post">
					<div class="layui-form-item">
						<div class="layui-inline">
						    <label class="layui-form-label">客户</label>
						    <div class="layui-input-inline">
								<select name="customerid" class="customerSel">
									<option value ="">请选择客户</option>
								</select>
						    </div>
						</div>
						<div class="layui-inline">
						    <label class="layui-form-label">商品名称</label>
						    <div class="layui-input-inline">
								<select name="goodsid" class="goodsSel">
									<option value ="">请选择商品</option>
								</select>
						    </div>
						</div>
						<div class="layui-inline">
						    <label class="layui-form-label">开始时间</label>
						    <div class="layui-input-inline">
						        <input type="text" name="startTime" id="startTime" readonly="readonly" autocomplete="off" class="layui-input">
						    </div>
						</div>
						<div class="layui-inline">
						    <label class="layui-form-label">结束时间</label>
						    <div class="layui-input-inline">
						        <input type="text" name="endTime" id="endTime" readonly="readonly" autocomplete="off" class="layui-input">
						    </div>
						</div>
					</div>
					<div class="layui-form-item" style="text-align: center">
						<div class="layui-inline">
							<button type="button" class="layui-btn layui-btn-normal  layui-icon layui-icon-search" lay-filter="doSearch" lay-submit="">查询</button>
							<button type="reset" class="layui-btn layui-icon layui-icon-refresh">重置</button>
						</div>
					</div>
		</form>
			</div>
		</fieldset>
		<!--搜索条件结束-->
	
<!--搜索条件结束-->

<!--数据表格开始-->
	
		<table class="layui-hide" id="SalesbackTable" lay-filter="SalesbackTable"></table>
	</div>
	
</div>
<!--数据表格结束-->





<script src="../../../../resources/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../../../resources/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../../resources/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="../../../../resources/lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
<script src="../../../../resources/common/jquery.cookie.min.js" charset="utf-8"></script>
<script src="../../../../resources/common/common.js" charset="utf-8"></script>

<script>
    layui.use(['jquery','layer','form','laydate','table'],function () {
        var form=layui.form;
        var $=layui.jquery;
        var layer=layui.layer;
        var laydate=layui.laydate;
        var table=layui.table;

        //渲染时间选择器
        laydate.render({
            elem:'#startTime',
            type:'datetime'
        })

        laydate.render({
            elem:'#endTime',
            type:'datetime'
        })
		
		//加载查询条件里面的客户的下拉列表
		$.get(api+"customer/getAllAvailableCustomer",function(res){
			var search_customerid=$(".customerSel");
			var html="<option value =''>请选择客户</option>";
			var data=res.data;
			$.each(data,function(index,item){
				html+="<option value ="+item.id+">"+item.customername+"</option>"
			});
			search_customerid.html(html);
			form.render("select");
		});
		
		//加载查询条件里面的商品的下拉列表
		$.get(api+"goods/getAllAvailableGoods",function(res){
			var search_goodsid=$(".goodsSel");
			var html="<option value =''>请选择商品</option>";
			var data=res.data;
			$.each(data,function(index,item){
				html+="<option value ="+item.id+">"+item.goodsname+"["+item.size+"]"+"</option>"
			});
			search_goodsid.html(html);
			form.render("select");
		});
		

        var tableIndex = table.render({
            elem: '#SalesbackTable'
            ,url: api+'salesback/loadAllSalesback'
            ,title: '退货表'
            ,page: true
            ,cols: [ [
                {field: 'id', title: 'ID', align: "center"},
				{field: 'customername',  title: '客户', align: "center"},
				{field: 'goodsname',  title: '商品名称', align: "center"},
				{field: 'size',  title: '规格', align: "center"},
				{field: 'salesbacktime',  title: '退货时间', align: "center"},
				{field: 'operateperson',  title: '操作人', align: "center"},
				{field: 'number',  title: '退货数量', align: "center"},
				{field: 'salebackprice',  title: '退货价格', align: "center"},
				{field: 'paytype',  title: '支付类型', align: "center"},
				{field: 'salesid',  title: '销售单ID', align: "center"},
                {field: 'remark',  title: '备注', align: "center"}
            ] ]
            ,done:function(data,curr,count){
                //不是第一页如果返回的数据为0那么就返回上一页
                if(data.data.length==0&&curr!=1){
                    tableIndex.reload({
                        page:{
                            curr:curr-1
                        }
                    });
                }
            }
        });

        //模糊查询
        form.on('submit(doSearch)',function(data){
            var params = $("#searchFrm").serialize();
            tableIndex.reload({
                url: api+"salesback/loadAllSalesback?" + params,
                page:{
                    curr:1
                }
            })
            return false;
        });

    })
</script>
</body>
</html>